@extends('admin.layout.layout')

@section('css')

    <link rel="stylesheet" href="{{asset('admin/layui/style/login.css')}}" media="all">

    <style>
        body{margin: 10px;}
        .demo-carousel{height: 200px; line-height: 200px; text-align: center;}
        .code {
            width: 400px;
            margin: 0 auto;
        }
        .input-val {
            width: 295px;
            background: #ffffff;
            height: 2.8rem;
            padding: 0 2%;
            border-radius: 5px;
            border: none;
            border: 1px solid rgba(0,0,0,.2);
            font-size: 1.0625rem;
        }
        #canvas {
            float: right;
            display: inline-block;
            border: 1px solid #ccc;
            border-radius: 5px;
            cursor: pointer;
        }
        .btn {
            width: 100px;
            height: 40px;
            background: #f1f1f1;
            border: 1px solid #ccc;
            border-radius: 5px;
            margin: 20px auto 0;
            display: block;
            font-size: 1.2rem;
            color: #e22e1c;
            cursor: pointer;
        }
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
    </style>


@endsection


@section('content')

    <div class="layadmin-user-login layadmin-user-display-show" id="LAY-user-login" style="display: none;">

        <div class="layadmin-user-login-main">
            <div class="layadmin-user-login-box layadmin-user-login-header">
                <h2>{{$companyName}}</h2>
                <p>后台管理系统</p>
            </div>
            <div class="layadmin-user-login-box layadmin-user-login-body layui-form">
                <div class="layui-form-item">
                    <label class="layadmin-user-login-icon layui-icon layui-icon-username" for="LAY-user-login-username"></label>
                    <input type="text" name="adminUserName" id="LAY-user-login-username" lay-verify="required" placeholder="用户名" class="layui-input">
                </div>
                <div class="layui-form-item">
                    <label class="layadmin-user-login-icon layui-icon layui-icon-password" for="LAY-user-login-password"></label>
                    <input type="password" name="password" id="LAY-user-login-password" lay-verify="required" placeholder="密码" class="layui-input">
                </div>

                @if(env('ADMIN_VERIFY_ENABLE',true))
                    <div class="layui-form-item">
                        <div class="layui-row">
                            <div class="layui-col-xs7">
                                <label class="layadmin-user-login-icon layui-icon layui-icon-vercode" for="LAY-user-login-vercode"></label>
                                <input type="text" name="verifyCode" id="LAY-user-login-vercode" lay-verify="required" placeholder="图形验证码" class="layui-input">
                            </div>
                            <div class="layui-col-xs5">
                                <div style="margin-left: 10px;">
                                    <img id="verifyCode" src="{{asset('/admin/getVerifyCodeImg')}}?h=50" class="layadmin-user-login-codeimg" id="LAY-user-get-vercode">
                                </div>
                            </div>
                        </div>
                    </div>
                @endif


                <div class="layui-form-item" style="margin-bottom: 20px;">
                    {{--<input type="checkbox" name="remember" lay-skin="primary" title="记住密码">
                    <a href="forget.html" class="layadmin-user-jump-change layadmin-link" style="margin-top: 7px;">忘记密码？</a>--}}
                </div>
                <div class="layui-form-item">
                    <button class="layui-btn layui-btn-fluid" lay-submit lay-filter="LAY-user-login-submit">登 入</button>
                </div>
                {{--<div class="layui-trans layui-form-item layadmin-user-login-other">
                    <label>社交账号登入</label>
                    <a href="javascript:;"><i class="layui-icon layui-icon-login-qq"></i></a>
                    <a href="javascript:;"><i class="layui-icon layui-icon-login-wechat"></i></a>
                    <a href="javascript:;"><i class="layui-icon layui-icon-login-weibo"></i></a>

                    <a href="reg.html" class="layadmin-user-jump-change layadmin-link">注册帐号</a>
                </div>--}}
            </div>
        </div>

        <div class="layui-trans layadmin-user-login-footer">

            <p>© {{date('Y')}} <a href="javascript:" target="_blank">{{$companyName}}</a></p>
            {{--<p>
                <span><a href="http://www.layui.com/admin/#get" target="_blank">获取授权</a></span>
                <span><a href="http://www.layui.com/admin/pro/" target="_blank">在线演示</a></span>
                <span><a href="http://www.layui.com/admin/" target="_blank">前往官网</a></span>
            </p>--}}
        </div>

    </div>

@endsection

@section('js')
    <script>
        lay.use(['index', 'user'], function(){
            var $ = layui.$
                ,setter = layui.setter
                ,admin = layui.admin
                ,form = layui.form
                ,router = layui.router()
                ,search = router.search

            function loginAction(){

                var userName = $("input[name=adminUserName]").val();
                var password = $("input[name=password]").val();
                var verifyCode = $("input[name=verifyCode]").val();


                admin.req({
                    url:'{{url('guard/login')}}'
                    //,data: obj.field
                    ,data: {'adminUserName':userName,'password':password,'verifyCode':verifyCode}
                    ,type:'post'
                    ,success: function(res){
                        if(res.status){
                            Dialog.msgSuccessFace(res.msg);
                            location.href = '{{url('guard/comeIn')}}'; //后台主页
                        }else{
                            Dialog.msgErrorFace(res.msg);
                            var url = '{{'/guard/getVerifyCodeImg'}}?time='+Math.random();
                            $("#verifyCode").attr('src',url);
                        }
                    }
                });
            }

            form.render();
            form.on('submit(LAY-user-login-submit)', function(obj){
                loginAction();
            });

            document.onkeydown = function (event) {
                if(event && event.keyCode==13){ // enter 键
                    loginAction();
                }
            };

            $("#verifyCode").click(function (){
                var url = '{{'/admin/getVerifyCodeImg'}}?time='+Math.random();
                $(this).attr('src',url);
            });

            Dialog.msgSuccessFaceOfTop('欢迎使用');
        });





    </script>
@endsection

